package org.jivesoftware.smackx.pubsub;

import java.util.Arrays;
import java.util.List;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;

public class EventElement
  implements EmbeddedPacketExtension
{
  private NodeExtension ext;
  private EventElementType type;

  public EventElement(EventElementType paramEventElementType, NodeExtension paramNodeExtension)
  {
    this.type = paramEventElementType;
    this.ext = paramNodeExtension;
  }

  public String getElementName()
  {
    return "event";
  }

  public NodeExtension getEvent()
  {
    return this.ext;
  }

  public EventElementType getEventType()
  {
    return this.type;
  }

  public List<PacketExtension> getExtensions()
  {
    PacketExtension[] arrayOfPacketExtension = new PacketExtension[1];
    arrayOfPacketExtension[0] = getEvent();
    return Arrays.asList(arrayOfPacketExtension);
  }

  public String getNamespace()
  {
    return PubSubNamespace.EVENT.getXmlns();
  }

  public String toXML()
  {
    StringBuilder localStringBuilder = new StringBuilder("<event xmlns='" + PubSubNamespace.EVENT.getXmlns() + "'>");
    localStringBuilder.append(this.ext.toXML());
    localStringBuilder.append("</event>");
    return localStringBuilder.toString();
  }
}